import request from '@/router/axios';
import {baseUrl} from "../../config/env";

export const getList = (current, size, params) => {
  return request({
    url: baseUrl +  '/api-gateway/route/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getDetail = (id) => {
  return request({
    url: baseUrl +  '/api-gateway/route/detail',
    method: 'get',
    params: {
      routeId: id
    }
  })
}

export const remove = (ids) => {
  return request({
    url: baseUrl +  '/api-gateway/route/'+ids,
    method: 'delete',
  })
}

export const add = (row) => {
  return request({
    url: baseUrl +  '/api-gateway/route/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: baseUrl + '/api-gateway/route/update',
    method: 'post',
    data: {
      id: row.id,
      routeId: row.routeId,
      predicates: JSON.parse(row.predicates),
      filters: JSON.parse(row.filters),
      uri: row.uri,
      sort: row.sort,
      description: row.description
    }
  })
}

export const sync = () => {
  return request({
    url: baseUrl +  '/api-gateway/route/sync',
    method: 'get',
    // data: row
  })
}

export const updateFlag = (row) => {
  return request({
    url: baseUrl +  '/api-gateway/route/updateFlag',
    method: 'get',
    data: row
  })
}


